import java.util.Scanner;

public class QianDao {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int n = scanner.nextInt();
        int s = scanner.nextInt();
        
        int cnt = 0, sum = 0;
        for (int i = 1; i <= n; i++) {
            int r = scanner.nextInt();
            int c = scanner.nextInt();
            
            if (r == 1) cnt++;
            sum += c;
        }
        
        System.out.println((cnt * 2 >= n ? 1 : 0) + " " + 
                          (sum - 50 >= s ? 1 : 0));
        
        scanner.close();
    }
}